import Mock from 'mockjs'

//提前生成大数组
var data = Mock.mock({
    "list|100": [
        {
            "id|+1": 1,
            "pic": '@image(300x200,@color)',
            "title": '@ctitle'
        }
    ]
})

//定义接口
Mock.mock('/carousel', 'post', function (options) {
    //解析参数
    var params = JSON.parse(options.body);
    var { count } = params;

    //截取指定数量的数据,返回
    var tempData = data.list.slice(0, count);
    return {
        "list": tempData
    }
})